package net.suplementos.web.action;

import java.util.Date;

import net.suplementos.dominio.TipoRelatorioVendas;
import net.suplementos.negocio.GerencialDelegate;
import net.suplementos.servico.GerencialServico;
import net.suplementos.web.LocalConstantes;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;

@Namespace("/relatorioVendas")
@InterceptorRefs({
	@InterceptorRef(value = "store", params = {"operationMode", "AUTOMATIC"}),
	@InterceptorRef("defaultStack")
})
public class RelatorioVendasAction extends ActionSupport {
	
	private GerencialServico gerencialServico = GerencialDelegate.getInstance();
	private Date dataInicio;
	private Date dataFim;
	private TipoRelatorioVendas tipo;

	@Action(value = "abrirConsultar", results = {
		@Result(name = SUCCESS, location = LocalConstantes.LOCAL_JSP_GERENCIAL_RELATORIO_VENDAS + "/consultar.jsp") 
	})
	public String abrirConsultar() throws Exception {
		return SUCCESS;
	}
	
	@Action(value = "relatorio", results = {
		@Result(name = SUCCESS, location = LocalConstantes.LOCAL_JSP_GERENCIAL_RELATORIO_VENDAS + "/relatorio.jsp") 
	})
	public String relatorio() throws Exception {
		gerencialServico.relatorioVendas(dataInicio, dataFim, tipo);
		return SUCCESS;
	}

	public Date getDataInicio() {
		return dataInicio;
	}

	public void setDataInicio(Date dataInicio) {
		this.dataInicio = dataInicio;
	}

	public Date getDataFim() {
		return dataFim;
	}

	public void setDataFim(Date dataFim) {
		this.dataFim = dataFim;
	}

	public TipoRelatorioVendas getTipo() {
		return tipo;
	}

	public void setTipo(TipoRelatorioVendas tipo) {
		this.tipo = tipo;
	}
}